﻿using MediatR;
using S.Archives.Domain.S.ArchivesDto;
using S.Archives.Infrstructre.InterFace;
using S.Archives.Read.Api.Application.Command;

namespace S.Archives.Read.Api.Application.CommandHandlers
{
    public class GetSheepFilesByEarTagCommandHandler : IRequestHandler<GetSheepFilesByEarTagCommand, SheepFileDto>
    {
        private readonly ISheepFileRepository sheepFile;
        public GetSheepFilesByEarTagCommandHandler(ISheepFileRepository sheepFile)
        {
            this.sheepFile = sheepFile;
        }
        public async Task<SheepFileDto> Handle(GetSheepFilesByEarTagCommand request, CancellationToken cancellationToken)
        {
            var list = sheepFile.GetSheepFiles().Result.FirstOrDefault(x => x.EarTag == request.EarTag);
            return  list;
        }
    }
}
